Skip to content

feat: add Markdown filter for hand-authored question sets - #23

Open
m-messer wants to merge 4 commits into
validatorfrom
markdown-filter
Open

m-messer wants to merge 4 commits into
validatorfrom
markdown-filter

Conversation

@m-messer

@m-messer m-messer commented Sep 1, 2026

Copy link
Copy Markdown
Member

A new Markdown filter parses a plain #/## markdown document into the Set/Question/Part model:

  • # → new question (heading is the title)
  • ## → new part
  • ## Solution → worked solution for the current part (or the whole question if it has no parts)
  • -a answers.md# advances to the next question, body blocks become worked solutions

This is the intermediate contract the wizard emits and hands back for review. runner() now runs check_markdown() over any markdown input and echoes a non-fatal warning per math-delimiter problem.

docs/source/filters.py learns to document a filter whose example is example.md (shown inline) instead of example.tex (rendered to a PDF).

Structure adapted from the Markdown2Lambda branch; the elaborate \st/\fa/\ws/*** syntax is dropped since the model only has question text, part text and one worked solution per part.


Stack: validator ← markdown-filter ← cli-group ← …
Base: validator#22.

🤖 Generated with Claude Code

A new "Markdown" filter parses a plain #/## markdown document into the
Set/Question/Part model:

- `#`            -> new question (heading is the title)
- `##`           -> new part
- `## Solution`  -> worked solution for the current part (or the whole
                    question if it has no parts)
- `-a answers.md` -> `#` advances to the next question, body blocks become
                     worked solutions

This is the intermediate contract the wizard will emit and hand back for
review. runner() now runs in2lambda.validation.check_markdown over any
markdown input and echoes a warning per math-delimiter problem (non-fatal).

docs/source/filters.py learns to document a filter whose example is
example.md (shown inline) instead of example.tex (rendered to a PDF), so the
new filter is picked up by the existing autosummary generation.

Structure adapted from the Markdown2Lambda branch; the elaborate
\st/\fa/\ws/*** syntax there is dropped since the Set/Question/Part model
only has question text, part text and one worked solution per part.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017VXb8aZqgFBjoeuuddjW6r
@peterbjohnson

Copy link
Copy Markdown
Member

Notes from reviewing this before merge. I ran this branch's filter (Python 3.11, pandoc installed) over a small probe file, and the structure of the source doesn't survive.

Probe file:

# Probe question

Some setup text.

## Part one

Do this, using:

- first item
- second item

## Solution

First step.

---

Second step after a separator.

Result from runner("probe.md", "Markdown"):

part 0 text:            'Do this, using:\n\nfirst itemsecond item'
part 0 worked_solution: 'First step.\n\nSecond step after a separator.'

Two things to note:

Lists (and tables) are flattened. first itemsecond item is what reaches the question. Anything that isn't a plain paragraph loses its structure, because every block goes through pf.stringify at filter.py:90, which returns text with no markup.

--- separators are dropped. That matters more than it looks: in a real Lambda Feedback export, --- is what splits a worked solution into the steps a student clicks through. Our own questions use 3 to 14 of them each. As it stands, a worked solution authored in Markdown can only ever be one step, and there's no way to ask for more.

The fix I'd suggest is not to hand the body to pandoc at all: split the raw text on the # and ## lines and keep each body exactly as written. The Lambda Feedback content is Markdown anyway, so passing it through untouched is both simpler and lossless, and it would make the images and inline code work by themselves.

Worth deciding too whether the ## heading text (Part one above) should be shown to students, since it currently disappears.

- Preserve `---` horizontal rules in Markdown question sets as solution step separators.
- Improve Markdown processing of inline elements, allowing lists, tables, and other markup to remain intact.
- Replace `pf.Str` with `pf.RawInline` for better fidelity when serializing inline Markdown elements (e.g., bold/italic text, images, math expressions).
- Update test cases to verify new behavior with horizontal rules and enhanced content parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants